package com.xbongbong.saas.model.impl;

import com.xbongbong.saas.domain.dao.OpenAppApiTokenDao;
import com.xbongbong.saas.domain.entity.OpenAppApiTokenEntity;
import com.xbongbong.saas.model.OpenAppApiTokenModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 接口
 * 创建时间 2019/10/9 9:03 PM
 * 修改时间 2019/10/9 9:03 PM
 * @author chy
 * @since v1.1.3
 * @version v1.1.3
 */
@Service("openAppApiTokenModel")
public class OpenAppApiTokenModelImpl implements OpenAppApiTokenModel {

    @Resource
    private OpenAppApiTokenDao openAppApiTokenDao;


    @Override
    public Integer insert(OpenAppApiTokenEntity entity) {
        return openAppApiTokenDao.insert(entity);
    }

    @Override
    public Integer update(OpenAppApiTokenEntity entity) {
        return openAppApiTokenDao.update(entity);
    }

    @Override
    public Integer save(OpenAppApiTokenEntity entity) {
        if(entity.getId() == null || Objects.equals(0L, entity.getId())) {
            return openAppApiTokenDao.insert(entity);
        }
        return openAppApiTokenDao.update(entity);
    }

    @Override
    public OpenAppApiTokenEntity getByKey(Integer openAppId, String corpid) {
        return openAppApiTokenDao.getByKey(openAppId, corpid);
    }

    @Override
    public List<OpenAppApiTokenEntity> findEntitys(Map<String, Object> param) {
        return openAppApiTokenDao.findEntitys(param);
    }
}
